[mirrors]
ftp://ftp.x.org/pub/individual/xserver/xorg-server-1.16.3.tar.bz2

[vars]
filesize=5806406
sha512=c0459ed95a6682b2094340b6b8fc7b59fcda5227ee2f13e87f68eb5c29b91cd3f05c5fc2126e33d6303beb3ad04d19466951ef4eb53f2e9918684cdaf3692c5a

[deps]
util-macros
pixman
xorg-proto-headers
xorg-libraries
libxkbfile
freetype
libfontenc
libxau
libxdmcp
libxfont
mesalib
libressl

[build]
printf "all:\n\ttrue\n\ninstall:\n\ttrue\n\n" > test/Makefile.in
sed -i 's/termio.h/termios.h/' hw/xfree86/os-support/xf86_OSlib.h

[ -n "$CROSS_COMPILE" ] && \
  xconfflags="--host=$($CC -dumpmachine) \
  --with-sysroot=$butch_root_dir"

LDFLAGS="$optldflags -Wl,-rpath-link=$butch_root_dir$butch_prefix/lib" \
CPPFLAGS="-D__gid_t=gid_t -D__uid_t=uid_t -DNOFILES_MAX=256 -D_GNU_SOURCE \
          -I$butch_root_dir$butch_prefix/include/pixman-1" \
CFLAGS=" $optcflags" \
  ./configure -C --prefix="$butch_prefix" $xconfflags \
    --disable-dmx --disable-xnest --disable-xephyr --disable-config-hal \
    --disable-kdrive --disable-xfbdev --disable-xwin --disable-xvfb \
    --disable-config-dbus  --disable-config-udev --enable-glx \
    --without-systemd-daemon --with-fontrootdir=/share/fonts \
    --disable-systemd-logind --enable-xorg

make V=1 -j$MAKE_THREADS
make DESTDIR="$butch_install_dir" install

# make /etc/X11 a symlink to /share/X11, so the config can be found easily
dest="${butch_prefix}${butch_install_dir}"
mkdir -p "$dest"/etc
ln -s ../share/X11 "$dest"/etc/

xmoddest="${butch_prefix}${butch_install_dir}"/share/X11/xorg.conf.d
mkdir -p "$xmoddest"
cp "$K"/20-modules.conf "$xmoddest"/

# FIXME starting X as non-root needs suid bit on the "server"
for i in Xfbdev Xorg ; do
	[ -e "$dest"/"$i" ] && chmod +s "$dest"/"$i"
done
